package com.t4.courseware.utils;

import org.apache.commons.lang3.RandomUtils;
import org.apache.commons.lang3.StringUtils;
import org.joda.time.DateTime;

public class FileUtils {

    public static String getOssFilePath(String rootDic, String originalFilename){
        DateTime dateTime = new DateTime();
        return rootDic + dateTime.toString("yyyy")
                + "/" + dateTime.toString("MM")
                + "/" + dateTime.toString("dd")
                + "/" + System.currentTimeMillis()
                + RandomUtils.nextInt(100, 999)
                + "." + StringUtils.substringAfterLast(originalFilename, "."); // 取出originalFilename中最后一个.后的字符串，即文件类型
    }

}
